var ConstCode = require('../constant/ConstCode');

module.exports = function (req, res, next) {
  var paths = [
    '/html/user/login.html',
    '/users/login',
    '/users/getLoginInfo'
  ];
  if (paths.includes(req.path)) {
    next();
  } else {
    var userid = req.session.userid;
    if (!userid) {
      return res.send({
        code: ConstCode.NOLOGIN_CODE,
        msg: '未登录'
      });
    }
    next();
  }
}